package com.scopionstudio.bean;

import java.net.URL;
import java.util.ArrayList;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;

import com.scopionstudio.utils.RessItems;

import android.widget.TextView;


public class RssParser {
	public ArrayList<RessItems> getList(String link)
	{ 
		try {
			URL url = new URL(link);
			SAXParserFactory spf = SAXParserFactory.newInstance(); 
			SAXParser parser = spf.newSAXParser(); 
		    XMLReader reader = parser.getXMLReader(); 
		    RssHandles dataHandler = new RssHandles();
		    reader.setContentHandler(dataHandler); 
		    InputSource source = new InputSource(url.openStream());
		    reader.parse(source); 
		    ArrayList<RessItems> result = dataHandler.getItemList();	
		    return result;
			} catch(Exception pce) { 
				pce.printStackTrace();
				return null;
		  } 
	}
}


